package com.ym.medical.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ym.core.utils.tkmybatis.BaseSVImpl;
import com.ym.core.utils.tkmybatis.TK;
import com.ym.medical.dao.PatientHealthRecordsDao;
import com.ym.medical.domain.entity.PatientHealthRecordsEntity;
import com.ym.medical.domain.param.PatientHealthRecordsParam;
import com.ym.medical.service.IPatientHealthRecordsSV;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * ComputerName:LAPTOP-6GI4HOI6
 * Author:625
 * Date: 2019-05-22
 * Time: 11:01:09
 * 服务实现类
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class PatientHealthRecordsSVImpl extends BaseSVImpl<PatientHealthRecordsEntity,PatientHealthRecordsDao> implements IPatientHealthRecordsSV {


    /**
     * 健康档案查询
     * @param patientId
     * @return
     */
    @Override
    public PatientHealthRecordsEntity selectByPatientId(Long patientId) {
        PatientHealthRecordsEntity p = mapper.selectOneByExample(
                TK.selectWhere(PatientHealthRecordsEntity.class)
                        .andNotEqualTo(PatientHealthRecordsEntity::getPatientId,patientId).end()
        );
        return p;
    }

    /**
     * 健康档案列表
     * @param pageNo
     * @param limit
     * @param patientHealthModel
     * @return
     */
    @Override
    public PageInfo<PatientHealthRecordsEntity> patientHealthList(int pageNo, int limit, PatientHealthRecordsParam patientHealthModel) {
        PageHelper.startPage(pageNo,limit);
        List<PatientHealthRecordsEntity> healthRecords = mapper.patientHealthList(patientHealthModel);
        return new PageInfo<>(healthRecords);
    }
}
